﻿using System;
using BusinessLogic.Models;
using BusinessLogic.Services;
using Framework;
using Framework.Bootstrappers;
using Framework.Dependency;
using Framework.Exceptions;
using Microsoft.Practices.Prism.Modularity;
using Microsoft.Practices.Unity;
using NewsDataProvider;
using SQLRepositories;
using YQLDataProvider;

namespace EconomicInformationServiceWcf
{
    public sealed class EisBootstrapper : UnityBootstrapper
    {
        protected override IUnityContainer CreateContainer()
        {
            return DependencyManager.Container;
        }

        protected override void ConfigureModuleCatalog()
        {
            AddModule(typeof(YqlDataProviderModule));
            AddModule(typeof(NewsDataProviderModule));
            AddModule(typeof(FiltersModule));
            AddModule(typeof(SqlRepositoryModule));
            AddModule(typeof(GenericModule));
            AddModule(typeof(ServicesModule));
            AddModule(typeof(LogicModelModule));
            AddModule(typeof(ServiceRigistrationModule));
        }

        private void AddModule(Type moduleType)
        {
            ModuleCatalog.AddModule(new ModuleInfo(moduleType.Name, moduleType.AssemblyQualifiedName));
        }

        public override void Run(bool runWithDefaultConfiguration)
        {
            ExceptionHandlingManager.Configure();
            base.Run(runWithDefaultConfiguration);
        }
    }
}